<?php

namespace app\common\order\logic;

use app\common\BaseLogic;
use app\common\config\logic\CommonPickerLogic;
use app\common\order\model\OrderIncome;
use app\common\system\logic\UserLogic;

class IncomeLogic extends BaseLogic
{

    public function getBrief($orderId)
    {
        /**
        $cacheName = "order:income:brief:{$orderId}";
        $data = $this->redis->hGetAll($cacheName);
        if (empty($data)) {

            $this->redis->hMSet($cacheName, $data);
        }
        **/

        $total = [];
        // 获取简介收款次数、收款总额、未收金额
        $model = new OrderIncome();
        $rows = $model->where('order_id', $orderId)->select();
        foreach ($rows as $row) {
            array_push($total, $row->total);
        }
        $data = [];
        $data['times'] = count($total);
        $data['collected'] = array_sum($total);
        $data['uncollected'] = 0;

        return $data;
    }
}